<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>修改密码 - 光年(Light Year Admin)后台管理系统模板</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
<meta name="author" content="yinqi">
<link href="/lib/css/bootstrap.min.css" rel="stylesheet">
<link href="/lib/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/lib/css/style.min.css" rel="stylesheet">
</head>
  
<body>
<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">
          
          <form method="post" action="#!" class="site-form">
            <div class="form-group">
              <label for="old-password">旧密码</label>
              <input type="password" class="form-control" name="oldpwd" id="old-password" placeholder="输入账号的原登录密码">
            </div>
            <div class="form-group">
              <label for="new-password">新密码</label>
              <input type="password" class="form-control" name="newpwd" id="new-password" placeholder="输入新的密码">
            </div>
            <div class="form-group">
              <label for="confirm-password">确认新密码</label>
              <input type="password" class="form-control" name="confirmpwd" id="confirm-password" placeholder="请输入新密码">
            </div>
            <button type="button"  onclick="changesub()" class="btn btn-primary">修改密码</button>
          </form>
 
        </div>
      </div>
    </div>
    
  </div>
  
</div>

<script type="text/javascript" src="/lib/js/jquery.min.js"></script>
<script type="text/javascript" src="/lib/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/lib/js/main.min.js"></script>
<script>
  function changesub() {
    if ($("#old-password").val().length>0){
      if ($("#new-password").val().length>0){
        if ($("#confirm-password").val().length>0){
          if($("#new-password").val()==$("#confirm-password").val()){
            $.ajax({
              url:"/user/editpwd",
              type:"post",
              data:{
                oldpassword:$("#old-password").val(),
                newpassword:$("#confirm-password").val()
              },
              success:function (message) {
                if (message.code==0){
                  alert("密码修改成功")
                  /*刷新页面*/
                  self.location.reload();
                }else {
                  alert("旧密码输入错误")
                }
              }
            })
          }else {
            alert("新密码与确认新密码不一致！")
          }
        }else {
          alert("请输入确认新密码")
        }
      }else {
        alert("请输入新密码")
      }
    }else {
      alert("请输入旧密码")
    }
  }
</script>
</body>
</html>